<?php

namespace App\Models\Register;

use App\Models\BaseModel;
use App\Services\UserRoleService;

/**
 * 激活用户管理
 * @author wuyu
 * @since 2023/4/16
 * Class AdminModel
 * @package App\Models
 */
class ActivateUserManagementModel extends BaseModel
{

    protected $connection = self::MYSQL_EVALUATION;
    // 设置数据表
    protected $table = 'activate_user_management';

    /**
     * 获取数据信息
     * @param int $id 用户ID
     * @return array|string
     * @author 牧羊人
     * @since 2020/11/10
     */
    public function getInfo($id)
    {
        $info = parent::getInfo($id); // TODO: Change the autogenerated stub
        if ($info) {
            // 头像
            if (!empty($info['avatar'])) {
                $info['avatar'] = get_image_url($info['avatar']);
            }
            // 获取用户角色列表
            $userRoleService = new UserRoleService();
            $roleList = $userRoleService->getUserRoleList($id);
            $info['roles'] = $roleList;
        }
        return $info;
    }
}

